import request from '@/utils/request.ts';
import type { loginParams, loginResponse, userInfoResponse, codeImageResponse, logoutResponse } from './type';



// 统一接口管理
enum API {
    CAP_IMAGE_URL = '/captchaImage',
    LOGIN_URL = '/login',
    USER_INFO_URL = '/getInfo',
    LOGOUT_URL = '/logout',
}

// 用户登录
export const reqLogin = (data: loginParams) => request.post<loginParams, loginResponse>(API.LOGIN_URL, data)

export const reqUserInfo = () => request.get<any, userInfoResponse>(API.USER_INFO_URL)


// 获取验证码
export const reqCodeImage = () => request.get<any, codeImageResponse>(API.CAP_IMAGE_URL)

// 退出登陆
export const reqLogout = (token:string) => request.post<any, logoutResponse>(API.LOGOUT_URL, token)



